//
//  CellForClickItem.m
//  ProjectA
//
//  Created by dllo on 16/1/28.
//  Copyright © 2016年 刘旺辉. All rights reserved.
//

#import "CellForClickItem.h"
#import "ModelForClickItem.h"
#import "NSString+HeightLabel.h"
#import <UIImageView+WebCache.h>
#import "AppMacro.h"
@interface CellForClickItem ()
@property (nonatomic, strong) UIImageView *photo_s;
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, assign) CGFloat height;
@property (nonatomic, assign) CGFloat width;
@end

@implementation CellForClickItem

- (void)dealloc {
    [_label release];
    [_photo_s release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.photo_s = [[UIImageView alloc] init];
        [self.contentView addSubview:self.photo_s];
        [_photo_s release];
        
        self.label = [[UILabel alloc] init];
        [self.contentView addSubview:self.label];
        [_label release];
    }
    return self;
}
#define WIDTH self.bounds.size.width - 40
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.photo_s.frame = CGRectMake(20, 5, WIDTH, self.height / self.width * WIDTH);
    self.label.frame = CGRectMake(20, 5 + 10 + self.photo_s.frame.size.height, WIDTH, [NSString heightForLabel:self.label.text withWidth:WIDTH withEdge:0 withFontOfSize:14]);
    self.label.numberOfLines = 0;
    self.label.font = [UIFont systemFontOfSize:13];
    
    [UIView setColorWithLabelText:self.label nightColor:L_COLOR_WHITE dayColor:RGBA(52, 52, 52, 1)];
    
    
}
- (void)passData:(ModelForClickItem *)model {
    self.height = model.photo_height.floatValue;
    self.width = model.photo_width.floatValue;
    [self.photo_s sd_setImageWithURL:[NSURL URLWithString:model.photo_s] placeholderImage:[UIImage imageNamed:@"iconfont-zhanweitu"]];
    self.label.text = model.text;
}
- (void)passData:(UIImage *)image withString:(NSString *)str {
    
    self.photo_s.image = image;
    self.label.text = str;
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
